﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Practice1.Model.Converter
{
    public class UserParamConverter:IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            //if (!values.Cast<string>().Any(text => string.IsNullOrEmpty(text)) && values.Length == 4)
            if (values.Length == 4)
            {
                UserParam up = new UserParam()
                {
                    UserName = values[0].ToString(), UserPhone = values[1].ToString(),
                    UserAddr = values[2].ToString(), UserSex = values[3].ToString()
                };

                return up;
            }

            return null;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
